/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dao;

import java.util.ArrayList;
import model.Loaidaugia;
import model.Thanhtoan;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import util.HibernateUtil;

/**
 *
 * @author HoangLiem
 */
public class LoaiDauGiaDAO {
     public static ArrayList<Loaidaugia> getAllBidTypes(){
        ArrayList<Loaidaugia> list = null;
        try{
            Session session = HibernateUtil.getSessionFactory().getCurrentSession();
            Transaction trans = session.getTransaction();
            trans.begin();
            String hql="from Loaidaugia";
            Query query = session.createQuery(hql);
            list = (ArrayList<Loaidaugia>)query.list();
            trans.commit();
        }catch(Exception ex){
            list = null;
            ex.printStackTrace();
        }
        return list;
    }
      public static Loaidaugia getABidType(int maLoaiDauGia){
        Loaidaugia abidType = null;
        try{
            Session session = HibernateUtil.getSessionFactory().getCurrentSession();
            Transaction trans = session.getTransaction();
            trans.begin();
            String hql="from Loaidaugia ldg where ldg.maLoaiDauGia=:maLoaiDauGia";
            Query query = session.createQuery(hql);
            query.setInteger("maLoaiDauGia", maLoaiDauGia);
            abidType = (Loaidaugia)query.uniqueResult();
            trans.commit();
        }catch(Exception ex){
            abidType = null;
            ex.printStackTrace();
        }
        return abidType;
    }
}
